<script lang="ts" setup>
import useStore from '../store';

import { watch } from 'vue'
const { news, channel } = useStore()
//watch 的第一个参数是 函数 ref对象 react对象
watch(
  () => channel.active,
  () => {
    news.getNewsList(channel.active)
  },
  {
    immediate:true
  }
)
</script>

<template>
  <div className="list">
    <div className="article_item"
     v-for="item in news.list" 
     :key="item.art_id">
    
      <h3 className="van-ellipsis">
         {{ item.title }}
      </h3>
      <div className="img_box" v-if="item.cover.type > 0">
        <img
          :src="item.cover.images[0]"
          className="w100"
          alt=""
        />
      </div>
      <div className="info_box">
        <span> {{ item.aut_name }}</span>
        <span>{{ item.comm_count }}评论</span>
        <span>{{ item.pubdate }}</span>
      </div>
    </div>
  </div>
</template>

<style scoed lang="less"></style>